/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AdminBooking.java
 *
 * Created on May 11, 2012, 6:53:09 PM
 */
package GUI.Admin;

import dao.LichChieuPhimDAO;
import dao.PhongChieuDAO;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import main.MainFormApp;
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.Task;
import pojo.Lichchieuphim;
import pojo.Phim;
import pojo.Phongchieu;
import pojo.Suatchieu;
import utils.BusyIndicator;

/**
 *
 * @author Hnmtuan
 */
public class AdminBooking extends javax.swing.JPanel {

    // <editor-fold defaultstate="collapsed" desc="Define all variables using this application">
    private SingleFrameApplication localApplication;
    private BusyIndicator localBusy;
    private ActionMap _rsActionMap;
    private DefaultTableModel _roomModel, _filmModel, _dateModel, _showTimesModel;
    private Lichchieuphim _ownedSchedules;
    private List<Phim> _films;
    private List<Phongchieu> _rooms;
    private List<Date> _dates;
    private List<Suatchieu> _showTimes;
    private List<Lichchieuphim> _schedules;
    private boolean bookingNew;
    // </editor-fold>
    //<editor-fold defaultstate="collapsed" desc="Define messages and error messages" >
    private final String MSG_BOOKING_DIALOG = "Booking details";
    private final String ERR_DATES_LIST_EMPTY = "Dates list is empty";
    private final String ERR_ROOMS_LIST_EMPTY = "Room list is empty";
    private final String ERR_FILMS_LIST_EMPTY = "Film list is empty";
    private final String ERR_SHOW_TIMES_LIST_EMPTY = "Show times list is empty";
    private final String ERR_SCHEDULE_LIST_EMPTY = "Schedules list is empty";
    private final String ERR_NOT_SELECTED_ROOM = "Room is not select";
    private final String ERR_NOT_SELECTED_FILM = "Film is not select";
    private final String ERR_NOT_SELECTED_DATE = "Date is not select";
    private final String ERR_NOT_SELECTED_SHOWTIMES = "Showtime is not select";
    private final String ERR_INVALID_PARAMS = "Param is invalid";
    private final String ERR_BOOKING_CANCEL = "Booking cancel";
    //</editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Define Constructor" >

    public AdminBooking(SingleFrameApplication appContext, BusyIndicator busy) throws Exception {
        localApplication = appContext;
        localBusy = busy;
        initComponents();
        initActions();
        // Init actions for jtbRoom, jtbFilm, jtbDate, jtbShowTime, btnBooking
        loadRooms();
        // Load room which exist schedule tables
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Define Init Actions" >

    private void initActions() throws Exception {
        _rsActionMap = Application.getInstance(main.MainFormApp.class).getContext().getActionMap(getClass(), this);
        jbtnBooking.setAction(_rsActionMap.get("bookingPlace"));
        jtbRooms.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            // -->>> not revoiked event throws exception

            public void valueChanged(ListSelectionEvent e) {
                try {
                    if (!isSelectedRoom()) {
                        return;
                    }
                    loadFilms();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
        jtbFilms.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            // -->>> not revoiked event throws exception

            public void valueChanged(ListSelectionEvent e) {
                try {
                     if (!isSelectedFilm()) {
                        return;
                    }
                    loadDates();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
        jtbDates.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            // -->>> not revoiked event throws exception

            public void valueChanged(ListSelectionEvent e) {
                try {
                     if (!isSelectedDate()) {
                        return;
                    }
                    loadShowTimes();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
        jtbShowTimes.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            // -->>> not revoiked event throws exception

            public void valueChanged(ListSelectionEvent e) {
                try {
                    if (!isSelectedShowTime()){
                        return;
                    }
//                    getSelectedSchedules();
                    setBooking(true);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Implement All Actions">

    @Action(enabledProperty = "booking")
    public Task bookingPlace() {
        Task task = new BookingTask();
//        task.setInputBlocker(new BusyIndicatorInputBlocker(task, this.localBusy));
        return task;
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Implement All Property or State">

    public boolean isSelectedShowTime() {
        return jtbShowTimes.getSelectedRow() != -1;
    }

    public boolean isSelectedDate() {
        return jtbDates.getSelectedRow() != -1;
    }

    public boolean isSelectedRoom() {
        return jtbRooms.getSelectedRow() != -1;
    }

    public boolean isSelectedFilm() {
        return jtbFilms.getSelectedRow() != -1;
    }

    public boolean isBooking() {
        return bookingNew;
    }

    public void setBooking(boolean newState) {
        if (bookingNew != newState) {
            this.bookingNew = newState;
            firePropertyChange("booking", !this.bookingNew, this.bookingNew);
        }
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Implement Actions to GUI" >

    protected final void refreshState() {
        // disable booking button
        setBooking(false);
        jtbRooms.clearSelection();
        // clear content showtimes
        _showTimesModel = (DefaultTableModel) jtbShowTimes.getModel();
//        _showTimesModel.setRowCount(0);
        _showTimesModel.getDataVector().removeAllElements();
        _showTimesModel.fireTableDataChanged();
        // clear content date
        _dateModel = (DefaultTableModel) jtbDates.getModel();
//        _dateModel.setRowCount(0);
        _dateModel.getDataVector().removeAllElements();
        _dateModel.fireTableDataChanged();
        // clear content film
        _filmModel = (DefaultTableModel) jtbFilms.getModel();
//        _filmModel.setRowCount(0);
        _filmModel.getDataVector().removeAllElements();
        _filmModel.fireTableDataChanged();

    }

    protected final void getSelectedSchedules() throws Exception {
        Suatchieu selectedShowtime = getSelectedShowTime();
        Date selectedDate = getSelectedDate();
        Phongchieu selectedRoom = getSelectedRoom();
        Phim selectedFilm = getSelectedFilm();
        Lichchieuphim cachedSchedule = null;
        try {
            _schedules = LichChieuPhimDAO.getLichChieuPhimsByRoomAndFilmAndDateAndShowtime(selectedRoom, selectedFilm, selectedDate, selectedShowtime);
            if (_schedules == null || _schedules.size() < 1) {
                throw new Exception(ERR_SCHEDULE_LIST_EMPTY);
            }
            cachedSchedule = _schedules.get(0);
            _ownedSchedules = cachedSchedule;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
//            LichChieuPhimDAO.closeCurrentSession();
        }
    }

    protected final Suatchieu getSelectedShowTime() throws Exception {
        if (!isSelectedShowTime()) {
            throw new Exception(ERR_NOT_SELECTED_SHOWTIMES);
        }
        int selectedIndex = jtbShowTimes.getSelectedRow();
        if (_showTimes == null || _showTimes.size() < 1) {
            throw new Exception(ERR_SHOW_TIMES_LIST_EMPTY);
        }
        Suatchieu tempShowTime = _showTimes.get(selectedIndex);
        return tempShowTime;
    }

    protected final Date getSelectedDate() throws Exception {
        if (!isSelectedDate()) {
            throw new Exception(ERR_NOT_SELECTED_DATE);
        }
        int selectedIndex = jtbDates.getSelectedRow();
        if (_dates == null || _dates.size() < 1) {
            throw new Exception(ERR_DATES_LIST_EMPTY);
        }
        Date tempDate = _dates.get(selectedIndex);
        return tempDate;
    }

    protected final Phim getSelectedFilm() throws Exception {
        if (!isSelectedFilm()) {
            throw new Exception(ERR_NOT_SELECTED_FILM);
        }
        int selectedIndex = jtbFilms.getSelectedRow();
        if (_films == null || _films.size() < 1) {
            throw new Exception(ERR_FILMS_LIST_EMPTY);
        }
        Phim tempFilm = _films.get(selectedIndex);
        return tempFilm;
    }

    protected final Phongchieu getSelectedRoom() throws Exception {
        if (!isSelectedRoom()) {
            throw new Exception(ERR_NOT_SELECTED_ROOM);
        }
        int selectedIndex = jtbRooms.getSelectedRow();
        if (_rooms == null || _rooms.size() < 1) {
            throw new Exception(ERR_ROOMS_LIST_EMPTY);
        }
        Phongchieu tempRoom = _rooms.get(selectedIndex);
        return tempRoom;
    }

    protected final void loadRooms() throws Exception {
        _roomModel = (DefaultTableModel) jtbRooms.getModel();
        _roomModel.getDataVector().clear();
        try {
            List<Phongchieu> tempRooms = PhongChieuDAO.getPhongChieus();
            if (tempRooms == null) {
                throw new Exception(ERR_ROOMS_LIST_EMPTY);
            }
            _rooms = new ArrayList<Phongchieu>();
            int count = 0;
            for (Phongchieu room : tempRooms) {
                if (room.getLichchieuphims().size() > 0) {
                    _rooms.add(room);
                    Vector v = new Vector();
                    count = count + 1;
                    v.addElement(count);
                    v.addElement(room.getTenPhong());
                    _roomModel.addRow(v);
                }
            }
            jtbRooms.setModel(_roomModel);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        } finally {
            PhongChieuDAO.closeCurrentSession();
        }
    }

    protected final void loadFilms() throws Exception {
        _filmModel = (DefaultTableModel) jtbFilms.getModel();
        _filmModel.getDataVector().clear();
        try {
            Phongchieu selectedRoom = getSelectedRoom();
            _schedules = LichChieuPhimDAO.getLichChieuPhimsByRoom(selectedRoom);
            if (_schedules == null) {
                throw new Exception(ERR_SCHEDULE_LIST_EMPTY);
            }
            List<Phim> cachedFilms = new ArrayList<Phim>();
            for (Lichchieuphim schedule : _schedules) {
                Phim cachedFilm = schedule.getPhim();
                cachedFilms.add(cachedFilm);
                cachedFilm = null;
            }
            int sizeFilm = cachedFilms.size();
            if (sizeFilm > 1) {
                List<Phim> cleanedFilms = new ArrayList<Phim>();
                for (Phim film : cachedFilms) {
                    if (!cleanedFilms.contains(film)) {
                        cleanedFilms.add(film);
                    }
                }
                _films = cleanedFilms;
                cleanedFilms = null;
                cachedFilms = null;
            } else {
                _films = cachedFilms;
                cachedFilms = null;
            }
            if (_films == null || _films.size() < 1) {
                throw new Exception(ERR_FILMS_LIST_EMPTY);
            }
            int count = 0;
            for (Phim film : _films) {
                Vector v = new Vector();
                count = count + 1;
                v.addElement(count);
                v.addElement(film.getTenPhim());
                _filmModel.addRow(v);
            }
            jtbFilms.setModel(_filmModel);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        } finally {
            LichChieuPhimDAO.closeCurrentSession();
        }
    }

    protected final void loadDates() throws Exception {
        _dateModel = (DefaultTableModel) jtbDates.getModel();
        _dateModel.getDataVector().clear();
        try {
            Phongchieu selectedRoom = getSelectedRoom();
            Phim selectedFilm = getSelectedFilm();
            _schedules = LichChieuPhimDAO.getLichChieuPhimsByRoomAndFilm(selectedRoom, selectedFilm);
            if (_schedules == null) {
                throw new Exception(ERR_SCHEDULE_LIST_EMPTY);
            }
            List<Date> cachedDates = new ArrayList<Date>();
            for (Lichchieuphim schedule : _schedules) {
                Date cachedDate = schedule.getNgayChieu();
                cachedDates.add(cachedDate);
                cachedDate = null;
            }
            int sizeDate = cachedDates.size();
            if (sizeDate > 1) {
                List<Date> cleanedDates = new ArrayList<Date>();
                for (Date item : cachedDates) {
                    if (!cleanedDates.contains(item)) {
                        cleanedDates.add(item);
                    }
                }
                _dates = cleanedDates;
                cleanedDates = null;
                cachedDates = null;
            } else {
                _dates = cachedDates;
                cachedDates = null;
            }
            if (_dates == null || _dates.size() < 1) {
                throw new Exception(ERR_FILMS_LIST_EMPTY);
            }
            int count = 0;
            for (Date date : _dates) {
                Vector v = new Vector();
                count = count + 1;
                v.addElement(count);
                v.addElement(date);
                _dateModel.addRow(v);
            }
            jtbDates.setModel(_dateModel);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        } finally {
            LichChieuPhimDAO.closeCurrentSession();
        }
    }

    protected final void loadShowTimes() throws Exception {
        _dateModel = (DefaultTableModel) jtbShowTimes.getModel();
        _dateModel.getDataVector().clear();
        try {
            Date selectedDate = getSelectedDate();
            Phongchieu selectedRoom = getSelectedRoom();
            Phim selectedFilm = getSelectedFilm();
            _schedules = LichChieuPhimDAO.getLichChieuPhimsByRoomAndFilmAndDate(selectedRoom, selectedFilm, selectedDate);
            if (_schedules == null) {
                throw new Exception(ERR_SCHEDULE_LIST_EMPTY);
            }
            List<Suatchieu> cachedShowtimes = new ArrayList<Suatchieu>();
            for (Lichchieuphim schedule : _schedules) {
                Suatchieu cachedShowtime = schedule.getSuatchieu();
                cachedShowtimes.add(cachedShowtime);
                cachedShowtime = null;
            }
            int sizeDate = cachedShowtimes.size();
            if (sizeDate > 1) {
                List<Suatchieu> cleanedShowtimes = new ArrayList<Suatchieu>();
                for (Suatchieu item : cachedShowtimes) {
                    if (!cleanedShowtimes.contains(item)) {
                        cleanedShowtimes.add(item);
                    }
                }
                _showTimes = cleanedShowtimes;
                cleanedShowtimes = null;
                cachedShowtimes = null;
            } else {
                _showTimes = cachedShowtimes;
                cachedShowtimes = null;
            }
            if (_showTimes == null || _showTimes.size() < 1) {
                throw new Exception(ERR_SHOW_TIMES_LIST_EMPTY);
            }
            int count = 0;
            for (Suatchieu showTime : _showTimes) {
                Vector v = new Vector();
                count = count + 1;
                v.addElement(count);
                v.addElement(showTime.getCodeSuatChieu());
                v.addElement(showTime.getGioBatDau());
                v.addElement(showTime.getGioKetThuc());
                _dateModel.addRow(v);
            }
            jtbShowTimes.setModel(_dateModel);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        } finally {
            LichChieuPhimDAO.closeCurrentSession();
        }
    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Define Booking Task" >

    private class BookingTask extends Task<Void, Void> {

        public BookingTask() {
            super(localApplication);
        }

        @Override
        protected Void doInBackground() throws Exception {
            getSelectedSchedules();
            if (_ownedSchedules == null){
                throw new Exception(ERR_INVALID_PARAMS);
            }
            Lichchieuphim cachedSchedule = _ownedSchedules;
            JFrame mainFrame = MainFormApp.getApplication().getMainFrame();
            AdminBookingDialog tempBookingDialog = new AdminBookingDialog(mainFrame, true, cachedSchedule);
            tempBookingDialog.setPreferredSize(new Dimension(AdminBookingDialog.DEFAULT_WIDTH, AdminBookingDialog.DEFAUL_HEIGHT));
            tempBookingDialog.setLocationRelativeTo(mainFrame);
            MainFormApp.getApplication().show(tempBookingDialog);
            LichChieuPhimDAO.closeCurrentSession();
            return null;
        }

        @Override
        protected void cancelled() {
            setMessage(ERR_BOOKING_CANCEL);
        }

        @Override
        protected void failed(Throwable thrwbl) {
            setMessage(thrwbl.getMessage());
            try {
                LichChieuPhimDAO.closeCurrentSession();
            } catch (Exception ex) {
                setMessage(ex.getMessage());
            }
        }

        @Override
        protected void succeeded(Void t) {
            refreshState();
        }
    }
    // </editor-fold>

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtbRooms = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtbFilms = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jtbDates = new javax.swing.JTable();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jtbShowTimes = new javax.swing.JTable();
        jPanel7 = new javax.swing.JPanel();
        jbtnBooking = new javax.swing.JButton();

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("2. Choose Film"));
        jPanel3.setName("jPanel3"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 152, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 211, Short.MAX_VALUE)
        );

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(AdminBooking.class);
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jpnRoom.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jtbRooms.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nums", "Room"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtbRooms.setName("jtbRooms"); // NOI18N
        jtbRooms.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(jtbRooms);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
                .addContainerGap())
        );

        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("GUI/Admin/resources/AdminBooking"); // NOI18N
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("jpnFilm.border.title"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jtbFilms.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nums", "Film"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtbFilms.setName("jtbFilms"); // NOI18N
        jtbFilms.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(jtbFilms);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("jpnDate.border.title"))); // NOI18N
        jPanel5.setName("jPanel5"); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        jtbDates.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Num", "Date"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtbDates.setName("jtbDates"); // NOI18N
        jScrollPane4.setViewportView(jtbDates);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("jpnShowTimes.border.title"))); // NOI18N
        jPanel6.setName("jPanel6"); // NOI18N

        jScrollPane5.setName("jScrollPane5"); // NOI18N

        jtbShowTimes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nums", "Code", "Start Time", "End Time"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtbShowTimes.setName("jtbShowTimes"); // NOI18N
        jtbShowTimes.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane5.setViewportView(jtbShowTimes);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 703, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jpnActions.border.title"))); // NOI18N
        jPanel7.setName("jPanel7"); // NOI18N

        jbtnBooking.setText(resourceMap.getString("jbtnBooking.text")); // NOI18N
        jbtnBooking.setName("jbtnBooking"); // NOI18N

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(254, 254, 254)
                .addComponent(jbtnBooking, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(273, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jbtnBooking)
                .addContainerGap(19, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(27, 27, 27)
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JButton jbtnBooking;
    private javax.swing.JTable jtbDates;
    private javax.swing.JTable jtbFilms;
    private javax.swing.JTable jtbRooms;
    private javax.swing.JTable jtbShowTimes;
    // End of variables declaration//GEN-END:variables
}
